package com.icbc.cc.api;

import java.sql.Connection;
import java.sql.Statement;

import com.icbc.ctp.ioc.xmlconfig.FileSystemXmlApplicationContext;
import com.icbc.ctp.jdbc.JDBCTemplate;

public class DbUtil {
	
	/**
	 * 关闭语句.
	 * 
	 * @param statement
	 */
	public static void closeStatement(Statement statement) {
		if (statement != null) {
			try {
				statement.close();
			} catch (Exception e) {
			}
		}
	}
	
	/**
	 * 关闭连接.
	 * 
	 * @param conn
	 */
	public static void closeConnection(Connection conn) {
		if (conn != null) {
			try {
				conn.close();
			} catch (Exception e) {
			}
		}
	}
	
	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	public static JDBCTemplate getJDBCTemplate() throws Exception {
		return (JDBCTemplate) FileSystemXmlApplicationContext.get("jdbcTemplate");
	}
}
